import http from "wechat-http"

http.baseURL = 'https://smart-shop.itheima.net/index.php?s=/api'

http.token = '' || wx.getStorageSync('token')

// 请求拦截器
http.intercept.request = function(options) {
    // 扩展头信息
    const defaultHeader = {}
    // 添加运行平台
    defaultHeader.platform = 'MP-WEIXIN'
    // 身份认证
    defaultHeader['Access-Token'] = http.token
    // 与默认头信息合并
    options.header = Object.assign({}, defaultHeader, options.header)
    // 返回头信息
    return options
}

wx.http = http

export default http